#字典

# #字典的创建
# a={}
# b=dict()
# print(type(a))
# print(type(b))
#
# a={"姓名":'xbl','gender':'男'}
# #字典中对键的类型有约束,对值的类型没有约束
#
#
# #查找key
# a={
#     "name":'xbl',
#     'gender':'boy'
# }
# #1.in(键存在返回真,不存在返回假)
# print('name' in a)
# print('age' in a)
# #2.[]
# print(a['name'])
# #如果键不存在,会报错
# print(a['age'])


# #删除元素
# a={'name':'xbl','gender':'boy'}
# print(a)
# #删除元素用pop,参数是key,pop参数不能为空
# a.pop('name')
# print(a)
#
# for i in a:
#     print(i)


# #字典的遍历
# a={
#     'name':'xbl',
#     'gender':'boy',
#     'age':21,
# }
#
# print(a.keys())
# print(a.values())
# #1.通过key来遍历
# for key in a:
#     print(key,a[key])
# #2.通过items直接遍历
# for key,value in a.items():
#     print(key,value)


#列表和字典类型的变量不能作为key
